/*
 * this should be the header only for the driver, not shared with userspace programms!
 */
#ifndef LCPD_SCOPE_DRIVER
#define LCPD_SCOPE_DRIVER

#ifdef MODULE_AUTHOR
MODULE_AUTHOR("T.Kurmann, R.Woodtli, S.Eichenberger");
#endif
#ifdef MODULE_DESCRIPTION
MODULE_DESCRIPTION("lcpd-scope");
#endif
#ifdef MODULE_LICENSE
MODULE_LICENSE("GPL");
#endif
#ifdef MODULE_SUPPORTED_DEVICE
MODULE_SUPPORTED_DEVICE("lcpd-scope");
#endif

//Add debugging outputs
//#define DEBUG

#define VENDOR_ID_ALTERA 0x1172
#define DEVICE_ID_ALTERA 0x0100
#define VENDOR_ID_XILINX 0x10ee
#define DEVICE_ID_XILINX 0x2010


#define MAJOR_NUM 100
#define IOCTL_SETDPY _IOR(MAJOR_NUM, 0, u16)
#define IOCTL_SETGPIO _IOR(MAJOR_NUM, 2, short int)
#define DEVICE_NAME "lcpd-scope"

#define SUCCESS 0

#define BUFFER_SIZE_ADDR 0x4
#define TRIGGER_ADDR 0x4020
#define GPIO_OFF 0x01
#define GPIO_ON 0x02

#define BASE_OFFSET_DATA 0x60

#define ADDRSAMPLERATE 0	// Address offset of SampleRate (Channel independent)
#define ADDRBUFFERSIZE 0	// Address offset of BufferSize (Channel independent)
#define ADDRCHA 20			// Address offset of Channel 1
#define ADDRCHB 40			// Address offset of Channel 2
#define ADDRTRIGGERLEV 0 	// Address offset of TriggerLevel
#define ADDRVOLTAGELEV 4 	// Address offset of VoltageLevel
// Defines for SPI
#define ADDRSPISPCR 0x4010	// SPI Control Register
#define ADDRSPISPSR 0x4004	// SPI Status Register
#define ADDRSPISPDR 0x4008	// SPI Data Register
#define ADDRSPISPER 0x400C	// SPI Extensions Register

#define MIN_BUFFER_SIZE 10
#define MAX_BUFFER_SIZE 2000
#define MIN_SAMPLING_RATE 10
#define MAX_SAMPLING_RATE 210000000

irqreturn_t device_interrupt(int irq, void *dev_id, struct pt_regs *regs);
static ssize_t device_read(struct file *file, char *buf, size_t size, loff_t *ppos);
char read_spi(char cSpiAddr);
int write_spi(char cSpiData, char cSpiAddr);
int init_spi(void);
int init_ADConverter(void);
int device_ioctl(struct inode *inode, struct file *file,
unsigned int ioctl_num, unsigned long ioctl_param);
static int device_open(struct inode *inode, struct file *file);
static int device_close(struct inode *inode, struct file *file);
int device_probe(struct pci_dev *dev, const struct pci_device_id *id);
void device_remove(struct pci_dev *dev);
static int init_module_DevicePCI(void);
void cleanup_module_DevicePCI(void);

#endif
